package com.person.leetcode.editor.cn;

import java.util.HashMap;

/**
  * 1.两数之和
  * 2022-03-30 17:24:27
**/
public class Sequence_0001_TwoSum {
    public static void main(String[] args) {
        Solution solution = new Sequence_0001_TwoSum().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            if (map.containsKey(target-num)){
                return new int[]{i,map.get(target-num)};
            }
            map.put(num, i);
        }
        return null;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}
